{include file="layout/layout" /}
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default;">
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <div class="subject">
        <h3>文章分类</h3>
        <h5>网站文章分类添加与管理</h5>
      </div>
    </div>
  </div>
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
      <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
      <span id="explanationZoom" title="收起提示"></span>
    </div>
    <ul>
      <li>新增文章时，可选择文章分类。文章分类将在前台文章列表页显示</li>
      <li>系统文章分类不可以删除</li>
    </ul>
  </div>
  <form method="post">
    <input name="form_submit" value="ok" type="hidden">
    <div class="flexigrid">
      <div class="mDiv">
        <div class="ftitle">
          <h3>文章分类列表</h3>
          <h5></h5>
        </div>
      </div>
      <div class="hDiv">
        <div class="hDivBox">
          <table cellspacing="0" cellpadding="0">
            <thead>
              <tr>
                <th class="sign" axis="col0" align="center">
                  <div style="text-align: center; width: 24px;"><i class="ico-check"></i></div>
                </th>
                <th class="handle" axis="col1" align="center">
                  <div style="text-align: center; width: 150px;">操作</div>
                </th>
                <!-- <th axis="col2" align="center">
                  <div style="text-align: center; width: 60px;">排序</div>
                </th> -->
                <th axis="col3" class="" align="center">
                  <div class="sundefined" style="text-align: center; width: 250px;">分类名称</div>
                </th>
                <th axis="col3" class="" align="center">
                  <div style="text-align: center; width: 350px;">分类描述</div>
                </th>
                <th axis="col4">
                  <div>
                </div>
                </th>
              </tr>
            </thead>
          </table>
        </div>
      </div>
      <div class="tDiv">
        <div class="tDiv2">
         <a href="{:url('Article/catAdd')}">
          <div class="fbutton">
            <div class="add" title="新增分类">
              <span><i class="fa fa-plus"></i>新增分类</span>
            </div>
          </div>
         </a>
        </div>
        <div style="clear:both"></div>
      </div>
      <div class="bDiv" style="height: auto;">
        <table class="flex-table autoht" id="article_cat_table" cellspacing="0" cellpadding="0" border="0">
          <tbody id="treet1">
            {foreach $catlist as $key=>$v}
            <tr nctype="0" class="parent_id_0" data-level="0">
              <td class="sign">
                <div style="text-align: center; width: 24px;">
                  <img src="__PUBLIC__/static/images/tv-expandable.gif" fieldid="2" status="open" nc_type="flex">
                </div>
              </td>
              <td class="handle">
                <div style="text-align:center;   min-width:150px !important; max-width:inherit !important;">
                  <span class="btn" style="padding-left:0em"><em><i class="fa fa-cog"></i>设置<i class="arrow"></i></em>
                  <ul>
                     <li><a href="{:url('Article/catEdit',['id'=>$v.cat_id])}">编辑分类信息</a></li>

                     <li><a href="javascript:;" onclick="delfun(this)" data-url="{:url('Article/delFun')}" data-id="{$v.cat_id}">删除此分类</a></li>
                  </ul>
                  </span>
                </div>
              </td>
              <!-- <td class="sort">
                <div style="text-align: center; width: 60px;">
                  <input onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onblur="changeTableVal('article_cat','cat_id','2','sort_order',this)" size="4" value="1" type="text">
                </div>
              </td> -->
              <td class="name">
                <div style="text-align: center; width: 250px;">
                  <!--<input type="text" value="购物指南" onblur="changeTableVal('article_cat','cat_id',2,'cat_name',this)" />-->
                    {$v.cat_name}
                </div>
              </td>
            <td class="name">
              <div style="text-align: center; width: 350px;">
                <span>{$v.cat_desc}</span>
              </div>
            </td>
              <td style="width: 100%;">
                <div>&nbsp;</div>
              </td>
            </tr>
            {/foreach}
          </tbody>
        </table>
      </div>
    </div>
  </form>
  <script>
     // 点击展开 收缩节点
     function treeClicked(obj,cat_id){
     var src = $(obj).attr('src');
     if(src == '/public/static/images/tv-expandable.gif')
     {
       $(".parent_id_"+cat_id).show();
       $(obj).attr('src','/public/static/images/tv-collapsable-last.gif');
     }else{
       $(obj).attr('src','/public/static/images/tv-expandable.gif');

       // 如果是点击减号, 遍历循环他下面的所有都关闭
       var tbl = document.getElementById("article_cat_table");
       cur_tr = obj.parentNode.parentNode.parentNode;
       var fnd = false;
        for (i = 0; i < tbl.rows.length; i++)
        {
          var row = tbl.rows[i];

          if (row == cur_tr)
          {
            fnd = true;
          }
          else
          {
            if (fnd == true)
            {

              var level = parseInt($(row).data('level'));
              var cur_level = $(cur_tr).data('level');

              if (level > cur_level)
              {
                $(row).hide();
                $(row).find('img').attr('src','/public/static/images/tv-expandable.gif');
              }
              else
              {
                fnd = false;
                break;
              }
            }
          }
        }
     }
   }

     function delfun(obj) {
       layer.confirm('确认删除？', {
                 btn: ['确定', '取消'] //按钮
               }, function () {
                 // 确定
                 $.ajax({
                   type: 'post',
                   url : $(obj).attr('data-url'),
                   data : {act:'del',cat_id:$(obj).attr('data-id')},
                   dataType: 'json',
                   success: function (data) {
                     layer.closeAll();
                     if (data.status == 1) {
                       layer.msg(data.msg, {icon: 1,time: 1000});
                       $(obj).parent().parent().parent().parent().parent().parent().remove();
                     }else{
                       layer.msg(data.msg, {icon: 2, time: 2000});
                     }
                   }
                 })
               }
       );
     }
  </script>
</div>
</body>
</html>